/*
Start from the bottom.
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define N 1000006
int n,m,L,V;
struct carr{
    int d,v,a;//d: position at time 0 v: speed at time 0 a:jsd of all the time
}qyc[100010];//car
int wyc[100010];//ce su yi
bool vis[1000010];
int pre[1000010];
vector<pair<int,int> > st;
void lhy(){
    st.clear();
    memset(vis,0,sizeof(vis));
    return ;
}
struct Segment{
    int dat[4*N],lazy[4*N];
    void init(){
        memset(dat,0,sizeof(dat));
        memset(lazy,0,sizeof(lazy));
        return ;
    }
    void pushdown(int l,int r,int x){
        int mid=(l+r)>>1;
        dat[x<<1]+=(mid-l+1)*lazy[x];
        dat[x<<1|1]+=(r-mid)*lazy[x];
        lazy[x<<1]+=lazy[x];
        lazy[x<<1|1]+=lazy[x];
        lazy[x]=0;
        return ;
    }
    void update(int l,int r,int L,int R,int x,int add){
        if(l>=L&&r<=R){
            dat[x]+=(r-l+1)*add;
            lazy[x]+=add;
            return ;
        }
        pushdown(l,r,x);
        int mid=(l+r)>>1;
        if(mid>=L)update(l,mid,L,R,x<<1,add);
        if(mid+1<=R)update(mid+1,r,L,R,x<<1|1,add);
        dat[x]=dat[x<<1]+dat[x<<1|1];
        return ;
    }
    int query(int l,int r,int L,int R,int x){
        if(l>=L&&r<=R){
            return dat[x];
        }
        pushdown(l,r,x);
        int mid=(l+r)>>1,res=0;
        if(mid>=L)res+=query(l,mid,L,R,x<<1);
        if(mid+1<=R)res+=query(mid+1,r,L,R,x<<1|1);
        dat[x]=dat[x<<1]+dat[x<<1|1];
        return res;
    }
}seg;
inline void wly(int i){
    if(qyc[i].v>V){
        if(qyc[i].a>=0){
            if(pre[L]-pre[qyc[i].d-1]>0)st.push_back(make_pair(qyc[i].d,L));
        }
        else{
            ll x=((ll)qyc[i].v*(ll)(qyc[i].v)-((ll)V*(ll)V))/(2LL*(ll)abs(qyc[i].a));
            if(x*(2LL*(ll)abs(qyc[i].a))>=((ll)qyc[i].v*(ll)(qyc[i].v)-((ll)V*(ll)V)))x--;
            x+=qyc[i].d;
            x=min(x,(ll)L);
            if(pre[x]-pre[qyc[i].d-1]>0)st.push_back(make_pair(qyc[i].d,x));
        }
    }
    else{
        if(qyc[i].a<=0)return ;
        else{
            ll x=((ll)V*(ll)V-((ll)qyc[i].v*(ll)qyc[i].v))/(2LL*(ll)(qyc[i].a));
            if(x*(2LL*(ll)(qyc[i].a))<=((ll)V*(ll)V-((ll)qyc[i].v*(ll)qyc[i].v)))x++;
            x+=qyc[i].d;
            if(x>L)return ;
            if(pre[L]-pre[x-1]>0)st.push_back(make_pair(x,L));
        }
    }
    return ;
}
inline bool cmp(const pair<int,int> &x1,const pair<int,int> &y1){
    if(x1.first<y1.first)return true;
    else if(x1.first==y1.first&&x1.second<y1.second)return true;
    else return false;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;lhy();
        L++;
        for(int i=1;i<=n;i++){
            cin>>qyc[i].d>>qyc[i].v>>qyc[i].a;
            qyc[i].d++;
        }
        for(int i=1;i<=m;i++){
            cin>>wyc[i];
            wyc[i]++;
            vis[wyc[i]]=1;
        }
        sort(wyc+1,wyc+m+1);
        pre[0]=0;
        for(int i=1;i<=L;i++){
            pre[i]=pre[i-1];
            if(vis[i])pre[i]++;
        }
        for(int i=1;i<=n;i++){
            wly(i);
        }
        cout<<st.size()<<" ";
        seg.init();
        sort(st.begin(),st.end(),cmp);
        int ans=0;
        for(int i=st.size()-1;i>=0;i--){
            if(seg.query(1,L,st[i].first,st[i].second,1)>0)continue;
            else{
                int pos=lower_bound(wyc+1,wyc+m+1,st[i].first)-wyc;
                if(wyc[pos-1]>=st[i].first)pos--;
                ans++;
                seg.update(1,L,wyc[pos],wyc[pos],1,1);
            }
        }
        cout<<m-ans<<endl;
    }
    return 0;
}
/*
duo ce bu qing kong
bao ling liang hang lei
*/